package com.ruoyi.web.controller.zsix;

import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.zsix.domain.model.SmsEntity;
import com.ruoyi.zsix.service.ISmsEntityService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/taskSms")
public class SystemConfigController extends BaseController {
    @Autowired
    private ISmsEntityService smsEntityService;

    /**
     * 获取抄送消息列表
     * @param sms
     * @return
     */
    @Log(title = "获取知会消息列表" , businessType = BusinessType.EXPORT)
    @PostMapping("/getCCSmsList")
    public TableDataInfo getCCSmsList(@RequestBody SmsEntity sms){
        startPage();
        List<SmsEntity> list=smsEntityService.ccSmsList(sms);
        return getDataTable(list);
    }

    /**
     * 获取消息列表
     * @param sms
     * @return
     */
    @Log(title = "获取消息列表" , businessType = BusinessType.EXPORT)
    @PostMapping("/getSmsList")
    public TableDataInfo getSmsList(@RequestBody SmsEntity sms){
        startPage();
        List<SmsEntity> list=smsEntityService.smsList(sms);
        return getDataTable(list);
    }
    /**
     * 设置消息已读
     * @param sms
     * @return
     */
    @Log(title = "设置消息已读" , businessType = BusinessType.EXPORT)
    @PostMapping("/readSms")
    public AjaxResult readSms(@RequestBody SmsEntity sms){
        return success(smsEntityService.updateState(sms));
    }

    /**
     * 删除消息
     * @param sms
     * @return
     */
    @Log(title = "删除消息" , businessType = BusinessType.EXPORT)
    @PostMapping("/system/deleteSms")
    public AjaxResult deleteSms(@RequestBody SmsEntity sms){
        return success(smsEntityService.deleteSms(sms));
    }
}
